#ifndef _ZR_API_H_
#define _ZR_API_H_

/*
 *	ZR_API.h
 *
 *	This header file defines all interfaces accessible to the ZR user code.
 *
 */

/** \mainpage Zero Robotics API Documentation
 * Use this documentation as a quick reference for the Zero Robotics C functions.
 * All ZR API functions are documented in ZR_API.h.
 * \see ZR_API.h
 */

/// @cond DEV
#ifndef _TMS320C6X
#include "mex.h"
#define DEBUG(arg) mexPrintf arg
#else
#define DEBUG(arg) 
#endif
/// @endcond

/**
 * Sets the x, y, and z forces to be applied to the satellite.  These forces will be added to any closed loop control
 * forces commanded by the satellite, so be careful about commanding forces and closed loop targets together.
 *
 * @param forces length 3 float array of forces
 *
 */
void ZRSetForces(float forces[3]);

/**
 * Sets the x, y, and z torques to be applied to the satellite.  These torques will be added to any closed loop control torques
 * commanded by the satellite.
 * @param torques length 3 float array of torques
 */
void ZRSetTorques(float torques[3]);

/**
 * Sets an x, y, and z position target for closed loop PD position control.  Cannot be combined
 * with velocity control.
 *
 * @param posTarget	length 3 float array of position targets
 */
void ZRSetPositionTarget(float posTarget[3]);

/**
 * Sets an x, y, and z velocity target for closed loop velocity control. Cannot be combined with
 * postion control.
 *
 * @param velTarget	length 3 float array of velocity targets
 */
void ZRSetVelocityTarget(float velTarget[3]);

/**
 * Specifies a unit vector for the satellite to point toward.  The satellite will move its -X face
 * (beacon/velcro face) to point at the specified (length 3) unit vector.
 * 
 * @param attTarget length 3 unit vector to point toward
 */
void ZRSetAttitudeTarget(float attTarget[3]);

/**
 * Sets the contents of the user debug vector sent at every control cycle.  Up to 12 values of type
 * "short" may be sent.
 *
 * @param dbgVals length 12 array of debugging values
 */
void ZRSetDebug(short dbgVals[12]);

/**
 * Initializes the API
 */
void ZRAPIInit();

#ifdef ZRFLATFLOOR
/**
 * Propagates the simulation forward each time an inertial task trigger is fired.  Must be added to the
 * gsp task.
 */
void sixDOFSimRun(unsigned int gsp_task_trigger, unsigned int extra_data);
#endif

/**
 * Main user code loop called at every iteration of gspControl (once per second).  Note: the multiple
 * declarations here are for competition purposes.  In simulation testing, implement your code in 
 * either your assigned number or ZRUser01.
 *
 *	@param	myState	length 12 state vector of user satellite [pos vel att_vector att_rates]
 *	@param	otherState	length 12 state vector of other satellite [pos vel att_vector att_rates]
 *	@param	time	time since the user code was activated (seconds)
 */
void ZRUser01(float *myState, float *otherState, float time);


/**
 * User code initialization called at the beginning of a test.  Use this section to reset stored values.
 */
void ZRInit01(void);

#ifndef SPH_MATLAB_SIM
#ifndef ZRSIMULATION
#define true 1
#define false 0
#endif
#endif
/* Note: the multiple declarations here are for competition purposes.  In simulation testing, 
 * cod is implemented in ZRInit01 and ZRUser01. */

/// @cond DEV
/* Additional ZRUser declarations */
void ZRUser02(float *myState, float *otherState, float time);
void ZRUser03(float *myState, float *otherState, float time);
void ZRUser04(float *myState, float *otherState, float time);
void ZRUser05(float *myState, float *otherState, float time);
void ZRUser06(float *myState, float *otherState, float time);
void ZRUser07(float *myState, float *otherState, float time);
void ZRUser08(float *myState, float *otherState, float time);
void ZRUser09(float *myState, float *otherState, float time);
void ZRUser10(float *myState, float *otherState, float time);
void ZRUser11(float *myState, float *otherState, float time);
void ZRUser12(float *myState, float *otherState, float time);
void ZRUser13(float *myState, float *otherState, float time);
void ZRUser14(float *myState, float *otherState, float time);
void ZRUser15(float *myState, float *otherState, float time);

/* Additional ZRInit declarations */
void ZRInit02();
void ZRInit03();
void ZRInit04();
void ZRInit05();
void ZRInit06();
void ZRInit07();
void ZRInit08();
void ZRInit09();
void ZRInit10();
void ZRInit11();
void ZRInit12();
void ZRInit13();
void ZRInit14();
void ZRInit15();

///@endcond

#endif
